package com.itheima.easyexcel.controller;
import com.itheima.easyexcel.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;


@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    public IUserService iUserService;

    //导出excel文件，下载文件
    @GetMapping("/excelExport")
    public void excelExport(HttpServletResponse response) throws Exception {
        iUserService.excelExport(response);
    }

    //导入文件，上传
    @PostMapping("/excelImport")
    public String excelImport(MultipartFile file) throws Exception {
        iUserService.excelImport(file);
        return "导入成功";
    }

}
